using Godot;

public partial class Enemy : Area2D
{
    [Export] public EntityStat Stats { get; private set; }
    private PathFollow2D _pathFollow;
    
    public override void _Ready()
    {
        Stats?.Initialize();
        _pathFollow = GetParent<PathFollow2D>();
    }

    public override void _Process(double delta)
    {
        if (_pathFollow != null)
        {
            // 沿路径移动
            float progress = (float)(Stats.MoveSpeed * Stats.SpeedModifier * delta);
            _pathFollow.Progress += progress;
        }
    }
    
    public void ApplyDamage(int damage)
    {
        Stats.TakeDamage(damage);
        if (Stats.CurrentHp <= 0)
        {
            QueueFree();
        }
    }
}
